#include<iostream>
#include<algorithm>
using namespace std;
const int N = 110;
struct node
{
	int l, r;
}s[N];
int cmp(node a, node b)
{
	if (a.l != b.l)return a.l < b.l;
	return a.r < b.r;
}
int n;
int main()
{
	int L;
	cin >> L >> n;
	for (int i = 1; i <= n; i++) {
		int l, r;
		cin >> l >> r;
		s[i] = { l,r };
	}
	sort(s + 1, s + n + 1, cmp);
	int ans = 0;
	int st = 0;
	int ed = -1;
	for (int i = 1; i <= n; i++) {
		if (ed < s[i].l) {
			ans += ed - st + 1;
			st = s[i].l;
			ed = s[i].r;
		}
		else {
			ed = max(ed, s[i].r);
		}
	}
	ans += ed - st + 1;
	cout << L - ans + 1 << endl;
	return 0;
}